package io.github.uicdb.badskill.api;

import com.mojang.logging.LogUtils;
import lombok.RequiredArgsConstructor;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.event.IModBusEvent;
import org.slf4j.Logger;

import java.util.function.Function;

@RequiredArgsConstructor
public class RegisterConsumerEvent extends Event implements IModBusEvent {
    private static final Logger LOGGER= LogUtils.getLogger();
    final ModContainer container;

    /**
     * @param name name
     * @param function a function to get you CostumerConsumer.
     */
    public void register(String name, Function<Player, CostumerConsumer> function){
        ResourceLocation resourceLocation=new ResourceLocation(container.getModId(),name);
        CostumerConsumerManager.register(resourceLocation,function);
        LOGGER.debug("Register consumer {}",resourceLocation);
    }
}
